var request = require('request'),
	cheerio = require('cheerio'),
	baseUrl = 'http://www.nasdaq.com/earnings/report/{0}',
	ticker = process.argv[2],
	url = baseUrl.replace('{0}', ticker),
	headers = { 
		'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'
	};
	
request.get({url: url, headers: headers}, function(err, resp, body) {
	var $ = cheerio.load(body),
		h2Text = $($('#left-column-div > h2').get(0)).text().trim(),
		elements = h2Text.split(':'),
		epsDate;

	if (elements.length !== 2)
	{
		return;
	}

	epsDate = elements[1].trim();

	console.log(epsDate);
});